package modelLayer;

import java.util.List;

public class Schedule {
	private String name;
	private Class cl;
	private List<Block> blocks;
	private int period;//period of schedule
	private int number;//number of lessons per week
	
	public Schedule(){
		
	}
	
	public Schedule(Class cl, int period, int number){
		setCl(cl);
		setPeriod(period);
		setNumber(number);
	}
	
	public Block createBlock(int number){
		Block block = new Block(number);
		return block;
	}
	
	public void addBlock(Block block){
		if (block != null && !blocks.contains(block)){
			blocks.add(block);
		}
	}
	
	public Block findBlock(int number){
		Block block = null;
		boolean found = false;
		for (int i = 0; !found && i < blocks.size(); i++){
			if (blocks.get(i).getNumber() == number){
				found = true;
				block = blocks.get(i);
			}
		}
		return block;
	}
	
	public void deleteBlock(int number){
		Block block = findBlock(number);
		if (block != null){
			blocks.remove(block);
		}
		
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Class getCl() {
		return cl;
	}

	public void setCl(Class cl) {
		this.cl = cl;
	}

	
	/**
	 * @return the blocks
	 */
	public List<Block> getBlocks() {
		return blocks;
	}

	/**
	 * @param blocks the blocks to set
	 */
	public void setBlocks(List<Block> blocks) {
		this.blocks = blocks;
	}

	/**
	 * @return the period
	 */
	public int getPeriod() {
		return period;
	}

	/**
	 * @param period the period to set
	 */
	public void setPeriod(int period) {
		this.period = period;
	}

	/**
	 * @return the number
	 */
	public int getNumber() {
		return number;
	}

	/**
	 * @param number the number to set
	 */
	public void setNumber(int number) {
		this.number = number;
	}
	
	public void updateBlockCollection(Block b) {
		// TODO Auto-generated method stub
		
	}

	public String toString() {
		return "Schedule for: " + cl.getClassName() + " have been created.";
	}

	
	
}
